Skip to content

perf: small wins — static bytes and inline hints - #108

Merged
kacy merged 2 commits into
mainfrom
perf/small-wins
Feb 12, 2026
Merged

perf: small wins — static bytes and inline hints#108
kacy merged 2 commits into
mainfrom
perf/small-wins

Conversation

@kacy

@kacy kacy commented Feb 12, 2026

Copy link
Copy Markdown
Owner

summary

tier 3 performance optimizations from the throughput/latency audit. low effort, low risk.

  • Bytes::from_static for pub/sub: serialize_sub_response now takes &'static [u8] for the event kind, eliminating one heap allocation per subscribe/unsubscribe response. the channel name still uses copy_from_slice since it's dynamic
  • #[inline] on hot-path functions: annotates Frame::serialize(), write_i64(), and parse_frame() for cross-crate inlining. these are called on every single request and sit at the protocol → server crate boundary

what was tested

  • cargo test --workspace --features protobuf — all tests pass
  • cargo clippy --workspace --features protobuf -- -D warnings — clean

kacy added 2 commits February 12, 2026 12:02
serialize_sub_response now takes &'static [u8] for the event kind,
using Bytes::from_static() instead of Bytes::copy_from_slice().
eliminates one heap allocation per subscribe/unsubscribe response.
annotates Frame::serialize(), write_i64(), and parse_frame() for
cross-crate inlining. these are called on every request and sit
at the protocol-server crate boundary where the compiler won't
inline without the hint (even with LTO, #[inline] is the correct
signal for functions this hot).
@kacy
kacy merged commit e425b6a into main Feb 12, 2026
6 of 7 checks passed
@kacy
kacy deleted the perf/small-wins branch February 12, 2026 17:27
kacy added a commit that referenced this pull request Feb 19, 2026
* perf: use Bytes::from_static for pub/sub event type strings

serialize_sub_response now takes &'static [u8] for the event kind,
using Bytes::from_static() instead of Bytes::copy_from_slice().
eliminates one heap allocation per subscribe/unsubscribe response.

* perf: add #[inline] to hot-path protocol functions

annotates Frame::serialize(), write_i64(), and parse_frame() for
cross-crate inlining. these are called on every request and sit
at the protocol-server crate boundary where the compiler won't
inline without the hint (even with LTO, #[inline] is the correct
signal for functions this hot).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant